package cn.wolfcode.luowowo.gold.service.impl;

import cn.wolfcode.luowowo.gold.domain.GoldProduct;
import cn.wolfcode.luowowo.gold.domain.GoldProductType;

import cn.wolfcode.luowowo.gold.mapper.GoldProductMapper;
import cn.wolfcode.luowowo.gold.mapper.GoldProductTypeMapper;
import cn.wolfcode.luowowo.gold.service.IGoldProductService;
import cn.wolfcode.luowowo.gold.vo.GoldIndexVO;

import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 猫教授
 * @date 2019/8/22 10:37
 */
@Service
public class IGoldProductServiceImpl implements IGoldProductService {
    @Autowired
    private GoldProductMapper goldProductMapper;
    @Autowired
    private GoldProductTypeMapper goldProductTypeMapper;

    @Override
    public List<GoldIndexVO> selectTop8ByTypeId() {
        //第一步查询出所有大分类
        List<GoldProductType> typeList=goldProductTypeMapper.selectBydeep(1);
        List<GoldIndexVO> voList=new ArrayList<>();
        for (GoldProductType type : typeList) {
            GoldIndexVO vo = new GoldIndexVO();
            List<GoldProduct> top8=goldProductMapper.selectByProductTypeParentId(type.getId());
            vo.setGoldProductType(type);
            vo.setTop8(top8);
            voList.add(vo);
        }
        return voList;
    }

    @Override
    public List<GoldProduct> selectpubLish() {
        return goldProductMapper.selectpubLish();
    }

    @Override
    public List<GoldProduct> selectAll() {
        return goldProductMapper.selectAll();
    }

    @Override
    public GoldProduct getOneById(Long productId) {




        return goldProductMapper.selectByPrimaryKey(productId);
    }
}
